﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel.Design.Serialization;
using System.ComponentModel;

namespace ArkhamHorrorHelper
{
    class MyTrackBar : System.Windows.Forms.TrackBar
    {
        private int _value = 0;
        private int _minimum = 0;
        private int _maximum = 10;

        /// <summary>
        /// Gets or sets a numeric value that represents the current position of the slider on the track bar.
        /// </summary>
        /// <remarks>The Value property contains the number that represents the current position of the slider on the track bar.</remarks>
        /// <value>A numeric value that is within the <see cref="Minimum"/> and <see cref="Maximum"/> range. 
        /// The default value is 0.</value>
        [Description("The current value for the MACTrackBar, in the range specified by the Minimum and Maximum properties.")]
        [Category("Behavior")]
        public int Value
        {
            get
            {
                return _value;
            }
            set
            {
                if (_value != value)
                {
                    if (value < _minimum)
                        _value = _minimum;
                    else
                        if (value > _maximum)
                            _value = _maximum;
                        else
                            _value = value;

                    OnValueChanged(_value);

                    this.Invalidate();
                }
            }
        }

        /// <summary>
        /// Raises the ValueChanged event.
        /// </summary>
        /// <param name="value">The new value</param>
        public virtual void OnValueChanged(int value)
        {
            // Any attached event handlers?
            //if (ValueChanged != null)
            //    ValueChanged(this, value);

        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Text = "test";
            base.OnPaint(e);
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle);
        }
    }
}
